<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="iso-8859-1"%>
<%@ include file="include.jsp" %>

<%--
PARAMETERS
  id: ID of file.
  video: Whether the file is a video (default false).
  playEnabled: Whether the current user is allowed to play songs (default true).
  addEnabled: Whether the current user is allowed to add songs to the playlist (default true).
  downloadEnabled: Whether the current user is allowed to download songs (default false).
  asTable: Whether to put the images in td tags.
--%>

<c:url value="/download.view" var="downloadUrl">
    <c:param name="id" value="${param.id}"/>
</c:url>

<c:if test="${param.asTable}"><td></c:if>
    <c:if test="${empty param.playEnabled or param.playEnabled}">
        <c:choose>
            <c:when test="${param.video}">
                <c:url value="/videoPlayer.view" var="videoUrl">
                    <c:param name="id" value="${param.id}"/>
                </c:url>
                <a href="${videoUrl}" target="_blank">
                    <img src="<spring:theme code="playImage"/>" alt="<fmt:message key="common.play"/>" title="<fmt:message key="common.play"/>"></a>
                </c:when>
                <c:otherwise>
                <a href="#" onclick="top.playQueue.onPlay(${param.id}); return false;">
                    <img src="<spring:theme code="playImage"/>" alt="<fmt:message key="common.play"/>" title="<fmt:message key="common.play"/>"></a>
                </c:otherwise>
            </c:choose>
        </c:if>
        <c:if test="${param.asTable}"></td></c:if>

<c:if test="${param.asTable}"><td></c:if>
    <c:if test="${(empty param.addEnabled or param.addEnabled) and not param.video}">
        <a href="#" onclick="top.playQueue.onAdd(${param.id}); return false;">
            <img src="<spring:theme code="addImage"/>" alt="<fmt:message key="common.add"/>" title="<fmt:message key="common.add"/>"></a>
        </c:if>
        <c:if test="${param.asTable}"></td></c:if>

<c:if test="${param.asTable}"><td></c:if>
    <c:if test="${param.downloadEnabled}">
        <a href="${downloadUrl}">
            <img src="<spring:theme code="downloadImage"/>" alt="<fmt:message key="common.download"/>" title="<fmt:message key="common.download"/>"></a>
        </c:if>
        <c:if test="${param.asTable}"></td></c:if>

<script type="text/javascript">
    $(function () {
        $.contextMenu({
            selector:'#add${param.id}',
            trigger:'left',
            callback:function (key, options) {
                if (key == "addnext") {
                    top.playQueue.onAddNext(${param.id});
                } else {
                    top.playQueue.onAdd(${param.id});
                }
            },
            items:{
                "addnext":{name:"<fmt:message key="main.addnext"/>"},
                "addlast":{name:"<fmt:message key="main.addlast"/>"}
            }
        });
    });
</script>